require("../../utils/util.js");

var e = require("../../requests/newapi.js").getCarNews;

Component({
    options: {
        multipleSlots: !0
    },
    properties: {
        modelshow: {
            type: Boolean,
            value: !1,
            observer: function(e, a, t) {}
        },
        modelinit: {
            type: Boolean,
            value: !1
        }
    },
    data: {
        reductionList: [],
        loading: !1,
        pageindex: 1,
        pagesize: 20,
        cityid: "",
        serialid: "",
        isEmpty: !1,
        winHeightAuto: 0,
        DealerBizMode: {
            1: "综合",
            2: "4S",
            3: "特许经销商"
        }
    },
    methods: {
        loadmore: function() {
            var e = this.data, a = e.cityid, t = e.serialid;
            this.data.isLoading || this.data.isEmpty || (this.setData({
                isLoading: !0
            }), this.showReduction(a, t));
        },
        showReduction: function(a, t) {
            var i = this;
            this.data.modelinit && this.setData({
                pageindex: 1,
                reductionList: []
            });
            var r = this.data, n = r.pageindex, d = r.pagesize, o = r.reductionList;
            e({
                op: "bit.dealer.promotionranklist",
                cityid: a,
                serialid: t,
                pagesize: d,
                pageindex: n
            }).then(function(e) {
                var r = e.Data;
                o && i.setData({
                    pageindex: n + 1,
                    reductionList: o.concat(r),
                    isLoading: !1,
                    isEmpty: r.length < d,
                    cityid: a,
                    serialid: t
                });
            }).catch(function(e) {
                console.log(e);
            });
        },
        telDealer: function(e) {
            wx.showModal({
                title: "拨打电话",
                content: "电话号码：" + e.currentTarget.dataset.tel,
                success: function(a) {
                    a.confirm && wx.makePhoneCall({
                        phoneNumber: e.currentTarget.dataset.tel
                    });
                }
            });
        },
        order: function(e) {
            var a = e.currentTarget.dataset, t = a.carid, i = a.cityid, r = a.dealerid, n = a.carimage, d = a.carname, o = a.dealername, s = a.subordertype;
            console.log(e.currentTarget.dataset), wx.navigateTo({
                url: "../xunjia/xunjia?carid=" + t + "&cityid=" + i + "&dealerid=" + r + "&img=" + n + "&carname=" + d + "&dealername=" + o + "&subordertype=" + s
            });
        },
        loan: function(e) {
            var a = e.currentTarget.dataset, t = a.carid, i = a.cityid, r = a.dealerid, n = a.carimage, d = a.carname, o = a.dealername, s = a.subordertype;
            wx.navigateTo({
                url: "../xunjia/xunjia?carid=" + t + "&cityid=" + i + "&dealerid=" + r + "&img=" + n + "&carname=" + d + "&dealername=" + o + "&subordertype=" + s
            });
        }
    }
});